Oracle® Database Globalization Development Kit Java API Reference
10g Release 2 (10.2)

Part No. B14224-02

oracle.i18n.text
Class UTF8ValidationFilter

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FilterInputStream
              |
              +--java.io.BufferedInputStream
                    |
                    +--oracle.i18n.text.UTF8ValidationFilter

public class UTF8ValidationFilter
extends BufferedInputStream

The UTF8ValidationFilter class is used to check the illegal UTF-8 byte sequence to replace with the replacement character U+FFFD or raise an exception.

The validation occurs transparently for the users. The output has the same contents as the input if an invalid UTF-8 sequence is not found. If an invalid UTF-8 sequence is found and UTF8ValidationFilter.ValidationBehavior.REPLACE is specified as the conversion behavior, the output will include U+FFFD, or 0xef, 0xbf, 0xbd in UTF-8 encoding where the problem occurs. By default, the illegal UTF-8 sequence is reported by the exception UTFDataFormatException.

Since:
10.2

Nested Class Summary
static class UTF8ValidationFilter.ValidationBehavior
          The ValidationBehavior class is the class used to determine the behavior in case the conversion fails.
 
Field Summary
 
Fields inherited from class java.io.BufferedInputStream
buf, count, marklimit, markpos, pos
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
UTF8ValidationFilter(InputStream in)
          Constructs the object with the InputStream object.
UTF8ValidationFilter(InputStream in, int size)
          Constructs the object with the InputStream object with the buffer size.
UTF8ValidationFilter(InputStream in, int size, UTF8ValidationFilter.ValidationBehavior action)
          Constructs the object with the InputStream object with the buffer size and the validation behavior.
 
Method Summary
 int read()
          Reads one byte.
 int read(byte[] b, int off, int len)
          Reads the byte array.
 
Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, reset, skip
 
Methods inherited from class java.io.FilterInputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UTF8ValidationFilter

public UTF8ValidationFilter(InputStream in)
Constructs the object with the InputStream object.

Parameters:
in - the InputStream object

UTF8ValidationFilter

public UTF8ValidationFilter(InputStream in,
                            int size)
Constructs the object with the InputStream object with the buffer size.

Parameters:
in - the InputStream object
size - the buffer size

UTF8ValidationFilter

public UTF8ValidationFilter(InputStream in,
                            int size,
                            UTF8ValidationFilter.ValidationBehavior action)
Constructs the object with the InputStream object with the buffer size and the validation behavior.

Parameters:
in - the InputStream object
size - the buffer size
action - specifies the error action to be either REPLACE or REPORT
Method Detail

read

public int read()
         throws UTFDataFormatException,
                IOException
Reads one byte.

Overrides:
read in class BufferedInputStream
Returns:
a byte from the input stream
Throws:
UTFDataFormatException - if any illegal UTF-8 sequence is found
IOException - if any other I/O error occurs

read

public int read(byte[] b,
                int off,
                int len)
         throws UTFDataFormatException,
                IOException
Reads the byte array.

Overrides:
read in class BufferedInputStream
Parameters:
b - buffer
off - offset
len - length
Returns:
the number of bytes copied
Throws:
UTFDataFormatException - if any illegal UTF-8 sequence is found
IOException - if any other I/O error occurs

Oracle® Database Globalization Development Kit Java API Reference
10g Release 2 (10.2)

Part No. B14224-02

Copyright © 2003, 2005, Oracle. All rights reserved.